﻿function openPrintWindow(url) {
    popupWin = window.open(url, 'open_window', 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0')
}

function ShowLoader(parentContainer) {
    var loaderContent = "<div id='loader'><table cellspacing='0' cellpadding='0'><tr><td>" + "Loading..." + "</td></tr><tr><td class='spinner'></td></tr></table></div>";
    if (parentContainer.children("#loader").length == 0) {
        parentContainer.append(loaderContent);
    }

    parentContainer.children().first().hide();
    parentContainer.find("#loader").show();
}

function HideLoader(parentContainer) {
    parentContainer.find("#container").show();
    parentContainer.find("#loader").hide();
}

function SubmitForm(form, callback, showLoader) {
    if (showLoader) {
        ShowLoader(form);
    }

    $.ajax({ type: "POST",
        url: form.attr("action"),
        data: form.serialize(),
        dataType: "application/JSON",
        success: function (result) {
            form.html(result);
            if (callback != null && callback.toString().length != 0) { eval(callback); }
        }
    });
}

function PostForm(form, callback) {
    $.ajax({ type: "POST",
        url: form.attr("action"),
        data: form.serialize(),
        dataType: "application/JSON",
        success: function (result) {
            if (callback != null && callback.toString().length != 0) { eval(callback); }
        }
    });
}